package com.rock.drawboard.ui.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.rock.drawboard.R;
import com.rock.drawboard.module.DataPackage;
import com.rock.drawboard.module.StrokeWidth;
import com.rock.drawboard.ui.adapter.GridImageAdapter;
import com.rock.drawboard.ui.adapter.GridTextAdapter;
import com.rock.drawboard.ui.view.SketchpadView;


public class GridViewSizeActivity extends Activity {

	GridView my_gridview ;
	GridTextAdapter myAdapter  ;
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.color_dialog);
			android.view.WindowManager.LayoutParams layoutParams=this.getWindow().getAttributes();
			layoutParams.width = 350;
			layoutParams.height = 350;
			this.getWindow().setAttributes(layoutParams);
	        my_gridview = (GridView) findViewById(R.id.grid );
			myAdapter=new GridTextAdapter(GridViewSizeActivity.this);
			my_gridview.setAdapter(myAdapter );
			my_gridview .setOnItemClickListener(new OnItemClickListener() {
				public void onItemClick(AdapterView<?> arg0,
										View arg1, int arg2, long arg3) {
					int size = 8;
					switch (arg2) {
						case 0:
							size = 8;
							break;
						case 1:
							size= 8 * 2;
							break;
						case 2:
							size= 8 * 3;
							break;
						case 3:
							size = 8 * 4;
							break;
						case 4:
							size = 8 * 5;
							break;
						case 5:
							size = 8 * 6;
							break;
					}
                    SketchpadView.sendDataToPc(DataPackage.DataType.STROKE, new StrokeWidth(size, SketchpadView.STROKE_PEN));
					SketchpadView.setStrokeSize(size, SketchpadView.STROKE_PEN);
					finish();
				}
			});

	  }
}
